# Contributor: Steeve Chailloux <steeve@chaahk.com>
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=apache-ant
pkgver=1.10.8
pkgrel=0
pkgdesc="A java-based build tool"
url="https://ant.apache.org/"
arch="noarch !mips !mips64"
options="!check"  # Needs itself for testing.
license="Apache-2.0"
depends="openjdk8-jre-base"
source="https://downloads.apache.org/ant/binaries/apache-ant-$pkgver-bin.tar.xz"

_anthome="/usr/share/java/$pkgname"

# secfixes:
#   1.10.8-r0:
#     - CVE-2020-1945

build() {
	cat > $pkgname.sh <<-EOF
	ANT_HOME="$_anthome"
	export ANT_HOME
	EOF
}

package() {
	local destdir="$pkgdir/$_anthome"

	install -dm755 "$destdir"/bin
	rm bin/*.bat bin/*.cmd
	install -m755 bin/* "$destdir"/bin

	install -dm755 "$pkgdir"/usr/bin
	ln -sf $_anthome/bin/ant "$pkgdir"/usr/bin/ant

	cp -r etc "$destdir"/

	install -dm755 "$destdir"/lib
	install -m644 lib/*.jar "$destdir"/lib

	# symlink to junit so it's on the javac build path for ant
	# matches behavior on ubuntu 9 and makes sense for compatibility
	# http://bugs.archlinux.org/task/15229
	ln -sf ../../junit.jar "$destdir"/lib/junit.jar

	# The license says the NOTICE file should be redistributed for
	# derivative works, so lets supply it.
	local file; for file in LICENSE NOTICE; do
		install -m644 -D $file "$pkgdir"/usr/share/licenses/$pkgname/$file
	done

	install -m644 -D $pkgname.sh "$pkgdir"/etc/profile.d/$pkgname.sh
}

sha512sums="b03be67dbda9b45a7838c304db7e6750e4907c6eef51a8de30d929f7e5b0da61b8a82fde2b590a0842acffc0f1098bc6bdfd16664a72c6c6f883990e166acdd4  apache-ant-1.10.8-bin.tar.xz"
